<!DOCTYPE>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="initial-scale=1.0, maximum-scale=1, user-scalable=no, width=device-width">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>全民抓抓</title>
  <link rel="stylesheet"  href="./css/appdown.css" />
  <script type="text/javascript" src="./js/PulickRem.js"></script>
</head>
<body>
  <div class="header">
    <div class="logo-wrapper">
      <img class="logo" src='./images/logo.png'/>
      <p class="title">全民抓抓</p>
    </div>
    <p class="head-p-1">随便抓 每个娃娃都好看！</p>
    <p  class="head-p-2">拒绝卡顿！ 行业延迟最低！</p>
  </div>
  <div class="main">
    <div class="main-bg">
      <div class="btn aos">安卓版下载</div>
      <div class="btn ios">IOS版下载</div>
    </div>
  </div>
  <div class="footer">
    <p class="foot-p-1">关注<span>《全民抓抓》</span>公众号</p>
    <p class="foot-p-2">更多福利等着大家哦</p>
    <div class="qr-code">
      <img class="img" src="./images/qrcode.png" />
    </div>
    <p class="foot-p-3">看这里！！！</p>
    <p class="foot-p-4">关注全民抓抓公众号 不用下载就可以抓娃娃啦</p>
  </div>
  <div class="mask"></div>
<script type="text/javascript" src="./js/zepto.min.js"></script>
<script>
  var TokenKey = null;
  var TokenValue = null;
  //是否微信
  function is_weixin(){ 
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger"){ return true; 
    }else{
      return false;
    }
  }

  //判断终端
  function checkPlatform(){
    if(/android/i.test(navigator.userAgent.toLowerCase())){
        return "android";
    }
    if(/|iphone|ipod|ipad|symbianos|ios/i.test(navigator.userAgent.toLowerCase())){
        return "ios";
    }
    return "android";
  }

  function getToken() {
    $.ajax({
        url: "https://passport.caiguo.com/api/token/get",
        type: "post",
        dataType: "json",
        data: {},
        success: function (res) {
            if (res.code === 'SUCCESS') {
                TokenKey = res.data.TokenKey;
                TokenValue = res.data.TokenValue
            }
        }
    });
  }

  getToken();
  checkPlatform();

  $('.mask').on('touchstart', function(){
    $('.mask').css('display', 'none');
  })
  
  $('.aos').on('click',function(){
    if(is_weixin()){
      $('.mask').css('display', 'block');
      return;
    }

    $.ajax({
      url: "https://platform.api.qmzhuazhua.com/openapi/appdown",
      type: 'post',
      data: {
        type: "Android",
      },
      headers: {
        'Token-Key': TokenKey,
        'Token-Value': TokenValue,
      },
      dataType: "json",
      success: function (res) {
          // console.log(res);
          if (res.code === 'SUCCESS') {
              var _url = res.data.file;
              location.href = _url;
          }
      }
    });
  })

  $('.ios').on('click',function(){
    if(is_weixin()){
      $('.mask').css('display', 'block');
      return;
    }

    $.ajax({
      url: "https://platform.api.qmzhuazhua.com/openapi/appdown",
      type: 'post',
      data: {
        type: "iOS",
      },
      headers: {
        'Token-Key': TokenKey,
        'Token-Value': TokenValue,
      },
      dataType: "json",
      success: function (res) {
          // console.log(res);
          if (res.code === 'SUCCESS') {
              var _url = res.data.file;
              location.href = _url;
          }
      }
    });
  })
</script>
</body>
</html>